package com.macro.mall.model;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * rc_registration_content实体类
 *
 * @author gaodx
 */
@Data
@Builder
@AllArgsConstructor
@ApiModel(description = "居委会&志愿者活动请求报文",value = "居委会&志愿者活动请求报文")
public class RcRegistrationContent implements Serializable {
    /***/
    @ApiModelProperty(value = "")
    private Integer id;
    /**
     * 社区id
     */
    @ApiModelProperty(value = "社区id")
    private String communityId;
    /**
     * 社区名称
     */
    @ApiModelProperty(value = "社区名称")
    private String communityName;
    /**
     * 居委会管理员id
     */
    @ApiModelProperty(value = "居委会管理员id")
    private String adminId;
    /**
     * 标题
     */
    @ApiModelProperty(value = "标题")
    private String title;
    /**
     * 01 - 志愿者
     */
    @ApiModelProperty(value = "01 - 志愿者 02-居委会办事指南")
    private String classified;
    /**
     * 来源
     */
    @ApiModelProperty(value = "来源")
    private String source;
    /**
     * 副标题
     */
    @ApiModelProperty(value = "副标题")
    private String subtitle;
    /**
     * 内容
     */
    @ApiModelProperty(value = "内容")
    private String content;
    /**
     * 电话号码
     */
    @ApiModelProperty(value = "电话号码")
    private String mobile;
    /**
     * 1-app 2-小程序  3-公众号
     */
    @ApiModelProperty(value = "1-app 2-小程序  3-公众号")
    private String channel;
    /**
     * 活动地址
     */
    @ApiModelProperty(value = "活动地址")
    private String addr;
    /**
     * 活动地址
     */
    @ApiModelProperty(value = "封面")
    private String image;
    /**
     * 生效时间
     */
    @ApiModelProperty(value = "生效时间")
    private Date stime;
    /**
     * 失效时间
     */
    @ApiModelProperty(value = "失效时间")
    private Date etime;
    /**
     * 报名开始时间
     */
    @ApiModelProperty(value = "报名开始时间")
    private Date sRegistration;
    /**
     * 报名结束时间
     */
    @ApiModelProperty(value = "报名结束时间")
    private Date eRegistration;
    /**
     * 报名人数
     */
    @ApiModelProperty(value = "报名人数")
    private String registration;
    /**
     * 审核状态 1-发布 2-审核中 3-审核不通过 4-审核通过 5-无效
     */
    @ApiModelProperty(value = "审核状态 1-发布 2-审核中 3-审核不通过 4-审核通过 5-无效")
    private String status;
    /**
     * 志愿活动状态 1-报名未开始 2-活动报名中 3-已报名 4-报名结束 5-活动结束
     */
    @ApiModelProperty(value = "志愿活动状态 1-活动未开始 2-活动结束 3-报名未开始 4-活动报名中 5-已报名 6-报名结束")
    private String flag;
    /**
     * 审核失败原因
     */
    @ApiModelProperty(value = "审核失败原因")
    private String reason;
    /**
     * 上次审核失败原因
     */
    @ApiModelProperty(value = "上次审核失败原因")
    private String beforeReason;
    /**
     * 排序
     */
    @ApiModelProperty(value = "排序")
    private String sort;
    /**
     * 0-非预约 1-预约
     */
    @ApiModelProperty(value = "0-非预约 1-预约")
    private String isAppointment;
    /***/
    @ApiModelProperty(value = "")
    private Date createTime;
    /***/
    @ApiModelProperty(value = "")
    private Date updateTime;
    @ApiModelProperty(value = "用户id")
    private String userId;

    @ApiModelProperty(value = "已报名人数")
    private Integer registrationNum;
    @ApiModelProperty(value = "上午工作时间")
    private String mornTime;
    @ApiModelProperty(value = "下午工作时间")
    private String afternoonTime;
    @ApiModelProperty(value = "是否被推荐  0-未推荐 1-已推荐")
    private String isRecommend;



    /**
     * 实例化
     */
    public RcRegistrationContent() {
        super();
    }

    /**
     * 实例化
     *
     * @param obj
     */


    public RcRegistrationContent(JSONObject obj) {
        this();
        if (obj.get("id") instanceof Number) {
            this.setId(((Number) obj.get("id")).intValue());
        }
        if (obj.get("title") instanceof String) {
            this.setTitle((String) obj.get("title"));
        }
        if (obj.get("classified") instanceof String) {
            this.setClassified((String) obj.get("classified"));
        }
        if (obj.get("source") instanceof String) {
            this.setSource((String) obj.get("source"));
        }
        if (obj.get("subtitle") instanceof String) {
            this.setSubtitle((String) obj.get("subtitle"));
        }
        if (obj.get("content") instanceof String) {
            this.setContent((String) obj.get("content"));
        }
        if (obj.get("mobile") instanceof String) {
            this.setMobile((String) obj.get("mobile"));
        }
        if (obj.get("channel") instanceof String) {
            this.setChannel((String) obj.get("channel"));
        }
        if (obj.get("addr") instanceof String) {
            this.setAddr((String) obj.get("addr"));
        }
        this.setStime((Date) obj.get("stime"));
        this.setEtime((Date) obj.get("etime"));
        this.setSRegistration((Date) obj.get("sRegistration"));
        this.setERegistration((Date) obj.get("eRegistration"));
        if (obj.get("registration") instanceof String) {
            this.setRegistration((String) obj.get("registration"));
        }
        if (obj.get("status") instanceof String) {
            this.setStatus((String) obj.get("status"));
        }
        if (obj.get("reason") instanceof String) {
            this.setReason((String) obj.get("reason"));
        }
        if (obj.get("beforeReason") instanceof String) {
            this.setBeforeReason((String) obj.get("beforeReason"));
        }
        if (obj.get("sort") instanceof String) {
            this.setSort((String) obj.get("sort"));
        }
        if (obj.get("isAppointment") instanceof String) {
            this.setIsAppointment((String) obj.get("isAppointment"));
        }
        this.setCreateTime((Date) obj.get("createTime"));
        this.setUpdateTime((Date) obj.get("updateTime"));
    }

   /* public String getFlag() {

        return flag;
    }

    public void setFlag(String flag) {
        long l = System.currentTimeMillis();
        //志愿活动状态 1-活动未开始 2-活动结束 3-报名未开始 4-活动报名中 5-已报名 6-名额已满

        if (!flag.equals("5") || !flag.equals("6")) {
            if (stime.getTime() > l) {
                this.flag = "1";
            } else if (etime.getTime() < l) {
                this.flag = "2";
            } else if (sRegistration.getTime() > l) {
                this.flag = "3";
            } else if (sRegistration.getTime() < l && eRegistration.getTime() > l) {
                this.flag = "4";
            }

        }
    }*/

    /**
     * 将当前对象转换为JsonObject
     *
     * @return
     */
    public JSONObject toJson() {
        JSONObject result = new JSONObject();
        if (this.getId() != null) {
            result.put("id", this.getId());
        }
        if (this.getTitle() != null) {
            result.put("title", this.getTitle());
        }
        if (this.getClassified() != null) {
            result.put("classified", this.getClassified());
        }
        if (this.getSource() != null) {
            result.put("source", this.getSource());
        }
        if (this.getSubtitle() != null) {
            result.put("subtitle", this.getSubtitle());
        }
        if (this.getContent() != null) {
            result.put("content", this.getContent());
        }
        if (this.getMobile() != null) {
            result.put("mobile", this.getMobile());
        }
        if (this.getChannel() != null) {
            result.put("channel", this.getChannel());
        }
        if (this.getAddr() != null) {
            result.put("addr", this.getAddr());
        }
        if (this.getStime() != null) {
            result.put("stime", this.getStime());
        }
        if (this.getEtime() != null) {
            result.put("etime", this.getEtime());
        }
        if (this.getSRegistration() != null) {
            result.put("sRegistration", this.getSRegistration());
        }
        if (this.getERegistration() != null) {
            result.put("eRegistration", this.getERegistration());
        }
        if (this.getRegistration() != null) {
            result.put("registration", this.getRegistration());
        }
        if (this.getStatus() != null) {
            result.put("status", this.getStatus());
        }
        if (this.getReason() != null) {
            result.put("reason", this.getReason());
        }
        if (this.getBeforeReason() != null) {
            result.put("beforeReason", this.getBeforeReason());
        }
        if (this.getSort() != null) {
            result.put("sort", this.getSort());
        }
        if (this.getIsAppointment() != null) {
            result.put("isAppointment", this.getIsAppointment());
        }
        if (this.getCreateTime() != null) {
            result.put("createTime", this.getCreateTime());
        }
        if (this.getUpdateTime() != null) {
            result.put("updateTime", this.getUpdateTime());
        }
        return result;
    }


    @Override
    public String toString() {
        return "RcRegistrationContent [id=" + id + " , title=" + title + " , classified=" + classified + " , source=" + source + " , subtitle=" + subtitle + " , content=" + content + " , mobile=" + mobile + " , channel=" + channel + " , addr=" + addr + " , stime=" + stime + " , etime=" + etime + " , sRegistration=" + sRegistration + " , eRegistration=" + eRegistration + " , registration=" + registration + " , status=" + status + " , reason=" + reason + " , beforeReason=" + beforeReason + " , sort=" + sort + " , isAppointment=" + isAppointment + " , createTime=" + createTime + " , updateTime=" + updateTime + "  ]";

    }


}
